<template xmlns="http://www.w3.org/1999/html">
  <sea-data-table ref="tableObject" url="/resource/mapping/page">
    <!--表头-->
    <sea-table-header slot="header" :params="form_data">
      <!--标题栏-->
      <sea-table-title slot="title" title="磁盘映射" subtitle=""></sea-table-title>

      <!--输入-->
      <template slot="input">
        <el-form-item label="名称" prop="keyword" for="keyword">
          <el-input size="small" v-model="form_data.keyword" id="keyword" placeholder="中/英"></el-input>
        </el-form-item>
        <el-form-item label="类型" prop="resourceType" for="resourceType">
          <sea-select size="small" v-model="form_data.resourceType" id="resourceType" placeholder="类型"
                      options="non.resource_type"></sea-select>
        </el-form-item>
      </template>

      <!--按钮栏-->
      <template slot="buttons">
        <el-button plain size="small" title="新增" icon="fa fa-plus" @click="onAction('new')"></el-button>
      </template>
    </sea-table-header>

    <!-- 弹窗、抽屉 -->
    <template slot="drawer">
      <sea-dialog ref="detail_dialog">
        <detail ref="detail"></detail>
      </sea-dialog>
    </template>

    <!--表头-->
    <template slot="columns">
      <el-table-column property="alias" label="资源名称" width="180"></el-table-column>
      <sea-col-dictionary property="resourceType" label="资源类别" width="180"
                             options="non.resource_type"></sea-col-dictionary>
      <el-table-column property="resourceIp" label="IP" width="180"></el-table-column>
      <el-table-column property="resourcePort" label="端口" width="180"></el-table-column>
      <el-table-column property="resourceUser" label="账号" width="180"></el-table-column>
      <el-table-column property="fileRoot" label="文件目录"></el-table-column>

      <!--操作栏-->
      <sea-table-actionbar width="180" :on-action="onAction" :buttons="buttons"></sea-table-actionbar>
    </template>
  </sea-data-table>
</template>

<script>
import detail from "./detail";

export default {
    components: {detail},
    data() {
        return {
            // 操作名称
            operation: undefined
            // 当前操作的行级对象
            , row_data: undefined
            // 操作栏
            , buttons: [
                {evt: 'edit', type: 'btn', label: '控制面板'}
            ]
            // 表单数据
            , form_data: {
                keyword: ''
                , resourceType: ''
            }
            // end--
        }
    },
    methods: {
        /**
         * 操作栏事件分发
         * @param evt 事件
         * @param row 行级对象
         */
        onAction: function (evt, row) {
            if (evt === 'edit') {
                let dialog = {title: `控制面板${row.alias}`, width: '70%'};
                this.$refs.detail_dialog.open(dialog).then(() => {
                    this.$refs.detail.setRowData(row)
                });
            }
        }
    }
}
</script>
